import { Api } from './api-service';
import { Injectable } from '@angular/core';
import { UserInfo } from '../global/ConstUrl';

/**
 * @author Jeremy115
 */
@Injectable()
export class UrlService {
	constructor(private api: Api) { }

	/**
	 * 获取用户信息
	 * @param key 
	 */
	getUserinfo(key) {
		return this.api.getUserinfo(key);
	}

	/**
 * 登录
 * @param userName 手机号
 * @param password 密码
 */
	login(userName: string, password: string) {
		return this.api.postBody('V1/LoginByPwd', { Mobile: userName, Pwd: password });
	}

	/**
	 * 
	 */
	auth_login() {
		return this.api.postBody('user/auth_login', {});
	}

	/**
	 * 获取注册验证码
	 * @param mobel 手机号
	 */
	getVcode(mobel: string, Type) {
		return this.api.postBody('V1/SendSMSVerification', { PhoneNumber: mobel, "Type": Type });
	}

	/**
	 * 注册
	 * @param phonenumber 手机号码
	 * @param vcode 验证码
	 * @param password  密码
	 */
	setRegister(phonenumber: string, vcode: string, password: string) {
		return this.api.postBody('V1/Register', { PhoneNumber: phonenumber, Code: vcode, Password: password });
	}

	/**
	 * 判断手机号是否注册
	 * @param phonenum 手机号
	 */
	CheckPhoneNumber(phonenum: string) {
		return this.api.postBody('V1/CheckPhoneNumber', { PhoneNumber: phonenum });
	}


	/**
	 * 重制密码
	 * @param phonenum 手机
	 * @param password1 密码
	 * @param vcode 验证码
	 */
	findPwd(phonenum: string, password1: string, vcode: string) {
		this.api.postBody('V1/RsetPassword', { PhoneNumber: phonenum, Password: password1, Code: vcode });
	}

	/**
	 * 第三方注册绑定手机号
	 * @param phonenum 手机号
	 * @param pwd 密码
	 * @param vcode 验证码 
	 * @param openid 第三方openid
	 */
	registerUser(phonenum: string, pwd: string, vcode: string, openid: string) {
		return this.api.postBody('V1/ThirdRegister', { PhoneNumber: phonenum, Password: pwd, Code: vcode, Title: '未设置', Type: 1, Context: openid });
	}

	/**
 * 首页获取数据
 */
	getHomeData() {
		return this.api.postBody('V1/GetHomeBanner', {});
	}
	/**
	 *  最新挑战
	 * @param page
	 */
	GetNewRecommendDekaron(page, PageSize) {
		return this.api.postBody('V1/GetNewRecommendDekaron', { PageIndex: page, PageSize: PageSize });
	}

	/**
	 * 
	 * 获取Url
	 */
	getUrl() {
	
	}

	/**
	 * 首页写入数据
	 */
	setHomeData() { }

	/**
   * 推荐挑战
   * @param page页数 
   */
	getChallengeList(page: number) {
		return this.api.postBody('V1/GetFirstInfo', { PageIndex: page, PageSize: 5 });
	}

	/**
	 * 推荐
	 * @param PageIndex 页数
	 */
	GetRecommendAllList(PageIndex) {
		return this.api.postBody("V1/GetRecommendAllList", { PageIndex: PageIndex, PageSize: 10 });
	}
	/**
	 * 文章详情
	 * @param id  文章id
	 */
	GetTcmsItemsInfo(id, userId) {
		return this.api.postBody("V1/GetTcmsItemsInfo", { "id": id, "UserId": userId });
	}

	/**
	 * 点赞
	 */
	InsertFabulous(id, user) {
		return this.api.postBody("V1/InsertFabulous", { ObjID: id, FabulousUserID: user });
	}
	/**
	 * 取消点赞
	 */
	DeteFabulous(id) {
		return this.api.postBody("V1/DeteFabulous", { ObjID: id });
	}

	/**
	 * 消息接口
	 */
	getMessageList(UserId, phoneNumber) {
		return this.api.postBody("V1/GetNewMessageInfo", { "PageIndex": 1, "PageSize": 10, "UserId": UserId, "PhoneNumber": phoneNumber });
	}

	/**
	 * 热门
	 * @param PageIndex 页数
	 */
	GeHotConversation(PageIndex, PageSize) {
		return this.api.postBody("V1/GeHotConversation", { PageIndex: PageIndex, PageSize: PageSize });
	}

	/**
	 * 
	 */
	openChat() {

	}


	/**
	 * 消息已读
	 */
	UpdatePushInfo(msgid) {
		return this.api.postBody("V1/UpdatePushInfo", { "ID": msgid });
	}

	/** 
	 * 推送红点
	 */
	GetPushCount() {
		return this.api.postBody("V1/GetPushCount", {});
	}

	/**
	 * 心路历程
	 */
	GetMyNewInfo() {
		return this.api.postBody("V1/GetMyNewInfo", {});
	}

	/**
	 * 自动加入
	 */
	GroupApplyFor(id, Creator, ApplyReason) {
		return this.api.postBody("V1/GroupApplyFor", { "Groupid": id, "Creator": Creator, "ApplyReason": ApplyReason });
	}


	/**
	 * 获取指定用户ID 用户信息
	 * @param personid 
	 */
	GetOtherInfo(personid) {
		return this.api.postBody("V1/GetOtherInfo", { "UserID": personid });
	}

	/**
	 * 用户详情
	 * 关注
	 * @param Type 
	 * @param personid 
	 */
	InsertRelationshipType(Type, personid) {
		return this.api.postBody("V1/InsertRelationshipType", { "UserId": UserInfo().UserID, "Type": Type ? 1 : 0, "RelationUserID": personid });
	}

	/**
	 * 个人详情--获取动态列表
	 */
	GetUserDekaronDynamicList(personid, index) {
		return this.api.postBody("V1/GetUserDekaronDynamicList", { "Userid": personid, "PageIndex": index, "PageSize": 20 });
	}
	/**
	 * 新建挑战
	 * @param data 
	 */
	InsertNewDekaronInfo(data) {
		return this.api.postBody("V1/InsertNewDekaronInfo", data);
	}
	/**
	 * 挑战分类
	 */
	GetDekaronClassify() {
		return this.api.postBody("V1/GetDekaronClassify", {});
	}
	/**
	 * 邀请好友
	 * @param index 
	 */
	GetMyfriendList(index) {
		return this.api.postBody("V1/GetMyfriendList",
			{
				"PageIndex": index,
				"PageSize": 50
			});
	}

	/**
	 *  
	 * 用户创建的 挑战
	 */
	GetUserInitiateDekaronInfo(personid, index, Classify, PageSize) {
		return this.api.postBody("V1/GetUserInitiateDekaronInfo", { "UserID": personid, "Classify": Classify, "PageIndex": index, "PageSize": PageSize });
	}

	/**
	 * 我的挑战-参加
	 * @param personid 
	 * @param index 
	 * @param Classify 
	 */
	GetUserJoinDekaronInfo(personid, index, Classify, PageSize) {
		return this.api.postBody("V1/GetUserJoinDekaronInfo", { "UserID": personid, "Classify": Classify, "PageIndex": index, "PageSize": PageSize });
	}




	/**
	 * GetUserIntegralList  战豆明细
	 * @param pageindex 页数
	 */
	GetUserIntegralList(pageindex) {
		return this.api.postBody("V1/GetUserIntegralList", { "PageIndex": pageindex, "PageSize": 5 });
	}


	/**
	 * GetUserCurrencyList 邀请明细
	 * @param pageindex  页数
	 */
	GetUserCurrencyList(pageindex) {
		return this.api.postBody("V1/GetUserCurrencyList", { "PageIndex": pageindex, "PageSize": 5 });
	}

	/**
	 * 获取 话题详情
	 * @param id 
	 * @param PageIndex 
	 */
	getConversationDetails(id, PageIndex) {
		return this.api.postBody("V1/GetConversationDetails", { id: id, PageIndex: PageIndex, PageSize: 10 });
	}
	/**
	 * 活动详情
	 * @param id  活动ID
	 */
	GetBaseDetails(id) {
		return this.api.postBody("V1/GetDekaronInfo", { id: id });
	}

	/**
	 * 
	 * @param pageindex 
	 */
	GetUserBillList(pageindex) {
		return this.api.postBody("V1/GetUserBillList", { "PageIndex": pageindex, "PageSize": 5 });
	}

	/**
	 * 转余额
	 * @param Currency 
	 */
	UpdateCurrencyRMB(Currency) {
		return this.api.postBody("V1/UpdateCurrencyRMB", { "Currency": Currency });
	}

	/**
	 * 评论列表
	 * @param id 被评论者的id 
	 * @param pageIndex 页数 
	 */
	GetEvaluateList(id, pageIndex) {
		return this.api.postBody("V1/GetEvaluateList", { ActivityID: id, PageIndex: pageIndex, PageSize: 10 });
	}
	/**
	 * 删除评论
	 * @param id 
	 */
	DeteEvaluate(id) {
		return this.api.postBody("V1/DeteEvaluate", { ID: id });
	}
	/**
	 * 
	 * 收藏挑战
	 * @param id 
	 * @param Type 10、30:收藏挑战  20、40:收藏话题
	 */
	InsertMyCollection(id, ObjType) {
		return this.api.postBody("V1/InsertMyCollection", { "ObjType": ObjType, "ObjID": id });
	}

	/**
	 *  
	 * 取消收藏
	 * 
	 */
	DeleteMyCollection(id) {
		return this.api.postBody("V1/DeleteMyCollection", { "ID": id });
	}




	/**
	 * 挑战详情
	 * @param DekaronId 
	 */
	GetDekaronInfo(DekaronId) {
		return this.api.postBody("V1/GetDekaronInfo", { id: DekaronId });
	}

	/**
	 * 获取热门
	 * @param pageindex 
	 */
	GetGroupListInfo(pageindex) {
		return this.api.postBody("V1/GetGroupListInfo", { PageIndex: pageindex, PageSize: 10 });
	}

	/**
	 * 我的兴趣小组
	 * @param pageindex 
	 */
	GetGroupRequest(pageindex) {
		return this.api.postBody("V1/GetGroupRequest", { PageIndex: pageindex, PageSize: 10 });
	}



	/**
	 * 获取动态
	 * @param userid 
	 * @param pageindex 
	 */
	GetGroupDynamicList(userid, pageindex) {
		return this.api.postBody("V1/GetGroupDynamicList", { Userid: userid, PageIndex: pageindex, PageSize: 10 });
	}


	/**
	 * 获取好友
	 * @param pageindex 
	 */
	GetMyFrendy(pageindex) {
		return this.api.postBody("V1/GetMyFrendy", { PageIndex: pageindex, PageSize: 10 });
	}




	/**
	* 获取用户信息
	* @param userId 
	*/
	getUser(userId) {
		return this.api.postBody('V1/GetUserInfo', { UserID: userId });
	}

	/**
	* 扫一扫
	*/
	GetbITMPUserInfo(code) {
		return this.api.postBody('V1/GetbITMPUserInfo', { id: code });
	}
}
